package com.jsj.service.impl;

import com.jsj.mapper.DeviceMapper;
import com.jsj.pojo.Device;
import com.jsj.pojo.Type;
import com.jsj.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceServiceImpl implements DeviceService {

    @Autowired
    DeviceMapper deviceMapper;

    @Override
    public List<Type> queryAllType() {
        List<Type> types = deviceMapper.queryAllType();
        return types;
    }

    @Override
    public List<Type> queryType(String type) {
        List<Type> types = deviceMapper.queryType(type);
        return types;
    }

    @Override
    public List<Device> queryListByType(String type) {
        List<Device> devices = deviceMapper.queryListByType(type);
        return devices;

    }

    @Override
    public Boolean addType(Type type) {
        Boolean flag = deviceMapper.addType(type);
        return flag;
    }

    @Override
    public Boolean delTypeById(int id) {
        Boolean flag = deviceMapper.delTypeById(id);
        return flag;
    }

    @Override
    public Boolean updateById(Type type) {
        Boolean flag = deviceMapper.updateById(type);
        return flag;
    }

    //以下是和device相关

    @Override
    public List<Device> queryDeviceByName(String type, String deviceName) {
        List<Device> devices = deviceMapper.queryDeviceByName(type,deviceName);
        return devices;
    }

    @Override
    public Boolean addDeviceByType(Device device) {
        Boolean flag = deviceMapper.addDeviceByType(device);

        return flag;
    }

    @Override
    public Boolean delDeviceById(int deviceId) {
        Boolean flag = deviceMapper.delDeviceById(deviceId);
        return flag;
    }

    @Override
    public Boolean updateDeviceById(Device device) {
        Boolean flag = deviceMapper.updateDeviceById(device);

        return flag;
    }

    @Override
    public Device queryByDeviceId(int deviceId) {
        Device device = deviceMapper.queryByDeviceId(deviceId);
        return device;
    }


}
